package com.lixw.initialize;

import com.lixw.config.RootConfig;
import com.lixw.config.WebConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * @ClassName: WebApplicationInitializer
 * @Description: Spring3.0+实现了Servlet3.0的初始化接口继承 AbstractAnnotationConfigDispatcherServletInitializer
 * 只需要指定配置类的所在和映射地址, 具体的容器初始化逻辑交由父类去做,这样既省去了web.xml配置,又省去了spring的配置文件
 * @Author: xuweiLi
 * @Create: 2025/6/24 21:19
 **/
public class WebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    /**
     * 指定Spring配置类
     * @return Spring配置类的Class
     */
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{RootConfig.class};
    }
    /**
     * 指定SpringMvc配置类
     * @return SpringMvc配置类的Class
     */
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{WebConfig.class};
    }

    /**
     * DispatchServlet的映射路径
     * @return 应去映射哪个地址
     */
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}